define([ "Zepto", "underscore", "Backbone", "Handlebars",
		"text!templates/faculty/guidefaculty.html",
		"views/faculty/corsolaurealistview", 
		"collections/corsolaureacollection", 
        "views/common/menuview"
		], function($, _, Backbone, Handlebars,
		template, CorsolaureaListView,CorsolaureaCollection, MenuView) {

	var GuideFacultyPage = Backbone.View.extend({

		template : Handlebars.compile(template),

		render : function(eventName) {
			
			this.$el.html(this.template(this.model.toJSON()));
			
			// menu top
			this.menutop = new MenuView({
				el : $('#menu', this.el),
				model : this.model
			});
			this.menutop.render();
			
			var clList = new CorsolaureaCollection();
			clList.fetch({
				query : {
					// seleziona le facoltà dell'università specificata
					facolta: {"__type":"Pointer","className":"facolta","objectId":this.model.get('objectId')}
					//id_facolta: this.model.get('objectId')
				},
				success: function(data) {
					this.listView = new CorsolaureaListView({
						el : $('#cdl ul', this.el),
						model : data
					});
					this.listView.render();
					return this;
				}
			});

		},

		events: {
            'touchstart .button': 'over',
            'touchend .button': 'left',
            'touchcancel .button': 'left',
            'touchstart button': 'over',
            'touchend button': 'left',
            'touchcancel button': 'left',
            'touchstart .ac-container article.selectable ul li': 'over',
            'touchend .ac-container article.selectable ul li': 'left',
            'touchcancel .ac-container article.selectable ul li': 'left'
        },

		over : function(event) {
			$(event.currentTarget).addClass('fake-active');
	﻿  ﻿  },

	﻿  ﻿  left : function(event) {
	﻿  ﻿  ﻿  $(event.currentTarget).removeClass('fake-active');
	﻿  ﻿  }

	});

	return GuideFacultyPage;

});
